import { Module } from '@nestjs/common';
import { UserModule } from './user/user.module';
import { LoginModule } from './login/login.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from 'nestjs-config';
import { RegisterModule } from './register/register.module';
import { UploadModule } from './upload/upload.module';
import { FriendModule } from './friend/friend.module';
import * as path from 'path';
import { MailmanModule } from '@squareboat/nest-mailman';
import { FriendApplicationModule } from './friend-application/friend-application.module';
import { SocketModule } from './socket/socket.module';
import { UserMessageModule } from './user-message/user-message.module';

@Module({
  imports: [
    ConfigModule.load(
      path.resolve(__dirname, 'config', '**', '!(*.d).{ts,js}'),
    ),
    TypeOrmModule.forRootAsync({
      useFactory: (config: ConfigService) => config.get('mysql.confog'),
      inject: [ConfigService],
    }),
    MailmanModule.registerAsync({
      useFactory: (config: ConfigService) => config.get('email.config'),
      inject: [ConfigService],
    }),
    LoginModule,
    RegisterModule,
    UserModule,
    UploadModule,
    FriendApplicationModule,
    FriendModule,
    SocketModule,
    UserMessageModule,
  ],
  controllers: [],
})
export class AppModule {}
